package cn.gson.crm.control.position;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.PositionDao;

/**
 * Servlet implementation class ChangeJobServlet
 */
@WebServlet("/changejob")
public class ChangeJobServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private PositionDao pd = new PositionDao();

	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String cId = request.getParameter("cpositionid");
		System.out.println(cId + "<----");
		String cpositionName = request.getParameter("cpositionName");
		String cdescription = request.getParameter("cdescription");
		if (cpositionName != null && !cdescription.isEmpty()) {
			if (pd.changePosition(cpositionName, cdescription, 2 + "")) {
				redirect("job");
			}
		} else {
			request.setAttribute("error", "职位名称不能为空");
			redirect("job");
		}
	}
}
